package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicOtherOutwhDAO;
import com.cssy.yd.logic.entity.LogicOtherOutwhDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-05-23
 */
public class LogicOtherOutwhDAOImpl extends SqlMapClientDaoSupport implements LogicOtherOutwhDAO {

    /**
     * 插入数据
     * @param logicOtherOutwhDO
     * @return 插入数据的主键
     */
    public String insertLogicOtherOutwhDO(LogicOtherOutwhDO logicOtherOutwhDO) throws DataAccessException {
    	logicOtherOutwhDO.setVersion(1);
        Object id = getSqlMapClientTemplate().insert("LogicOtherOutwh.insert", logicOtherOutwhDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicOtherOutwhDO
     * @return 查出的记录数
     */
    public Integer countLogicOtherOutwhDOByExample(LogicOtherOutwhDO logicOtherOutwhDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicOtherOutwh.countByDOExample", logicOtherOutwhDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicOtherOutwhDO
     * @return 受影响的行数
     */
    public Integer updateLogicOtherOutwhDO(LogicOtherOutwhDO logicOtherOutwhDO) throws DataAccessException {
    	logicOtherOutwhDO.setVersionbt(logicOtherOutwhDO.getVersion());
    	logicOtherOutwhDO.setVersion(logicOtherOutwhDO.getVersion()+1);
        int result = getSqlMapClientTemplate().update("LogicOtherOutwh.update", logicOtherOutwhDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicOtherOutwhDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicOtherOutwhDO> findListByExample(LogicOtherOutwhDO logicOtherOutwhDO) throws DataAccessException {
        List<LogicOtherOutwhDO> list = getSqlMapClientTemplate().queryForList("LogicOtherOutwh.findListByDO", logicOtherOutwhDO);
        return list;
    }

    /**
     * 根据主键获取logicOtherOutwhDO
     * @param id
     * @return logicOtherOutwhDO
     */
    public LogicOtherOutwhDO findLogicOtherOutwhDOByPrimaryKey(String id) throws DataAccessException {
        LogicOtherOutwhDO logicOtherOutwhDO = (LogicOtherOutwhDO) getSqlMapClientTemplate().queryForObject("LogicOtherOutwh.findByPrimaryKey", id);
        return logicOtherOutwhDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicOtherOutwhDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicOtherOutwh.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
    public List<LogicOtherOutwhDO> find(SearchConditions scs) throws DataAccessException{
		List<LogicOtherOutwhDO> list = getSqlMapClientTemplate().queryForList("LogicOtherOutwh_ex.find", scs);
   		   return list;
    }
    
	@Override
    public Integer count(SearchConditions scs) throws DataAccessException {		
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicOtherOutwh_ex.count", scs);
  	      return count;
  	}
}